/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package nxtmodel2.impl;

import nxtmodel2.Condition;
import nxtmodel2.Nxtmodel2Package;
import nxtmodel2.Property;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Condition</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link nxtmodel2.impl.ConditionImpl#getConditionProperty <em>Condition Property</em>}</li>
 *   <li>{@link nxtmodel2.impl.ConditionImpl#getType <em>Type</em>}</li>
 *   <li>{@link nxtmodel2.impl.ConditionImpl#getExpression <em>Expression</em>}</li>
 *   <li>{@link nxtmodel2.impl.ConditionImpl#getValue <em>Value</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ConditionImpl extends NxtElementImpl implements Condition {
	/**
	 * The cached value of the '{@link #getConditionProperty() <em>Condition Property</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConditionProperty()
	 * @generated
	 * @ordered
	 */
	protected Property conditionProperty;

	/**
	 * The default value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected static final String TYPE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected String type = TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #getExpression() <em>Expression</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExpression()
	 * @generated
	 * @ordered
	 */
	protected static final String EXPRESSION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getExpression() <em>Expression</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExpression()
	 * @generated
	 * @ordered
	 */
	protected String expression = EXPRESSION_EDEFAULT;

	/**
	 * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected static final String VALUE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected String value = VALUE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ConditionImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Nxtmodel2Package.Literals.CONDITION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Property getConditionProperty() {
		if (conditionProperty != null && conditionProperty.eIsProxy()) {
			InternalEObject oldConditionProperty = (InternalEObject)conditionProperty;
			conditionProperty = (Property)eResolveProxy(oldConditionProperty);
			if (conditionProperty != oldConditionProperty) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, Nxtmodel2Package.CONDITION__CONDITION_PROPERTY, oldConditionProperty, conditionProperty));
			}
		}
		return conditionProperty;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Property basicGetConditionProperty() {
		return conditionProperty;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setConditionProperty(Property newConditionProperty) {
		Property oldConditionProperty = conditionProperty;
		conditionProperty = newConditionProperty;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Nxtmodel2Package.CONDITION__CONDITION_PROPERTY, oldConditionProperty, conditionProperty));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getType() {
		return type;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType(String newType) {
		String oldType = type;
		type = newType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Nxtmodel2Package.CONDITION__TYPE, oldType, type));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getExpression() {
		return expression;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setExpression(String newExpression) {
		String oldExpression = expression;
		expression = newExpression;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Nxtmodel2Package.CONDITION__EXPRESSION, oldExpression, expression));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getValue() {
		return value;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValue(String newValue) {
		String oldValue = value;
		value = newValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Nxtmodel2Package.CONDITION__VALUE, oldValue, value));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Nxtmodel2Package.CONDITION__CONDITION_PROPERTY:
				if (resolve) return getConditionProperty();
				return basicGetConditionProperty();
			case Nxtmodel2Package.CONDITION__TYPE:
				return getType();
			case Nxtmodel2Package.CONDITION__EXPRESSION:
				return getExpression();
			case Nxtmodel2Package.CONDITION__VALUE:
				return getValue();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Nxtmodel2Package.CONDITION__CONDITION_PROPERTY:
				setConditionProperty((Property)newValue);
				return;
			case Nxtmodel2Package.CONDITION__TYPE:
				setType((String)newValue);
				return;
			case Nxtmodel2Package.CONDITION__EXPRESSION:
				setExpression((String)newValue);
				return;
			case Nxtmodel2Package.CONDITION__VALUE:
				setValue((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Nxtmodel2Package.CONDITION__CONDITION_PROPERTY:
				setConditionProperty((Property)null);
				return;
			case Nxtmodel2Package.CONDITION__TYPE:
				setType(TYPE_EDEFAULT);
				return;
			case Nxtmodel2Package.CONDITION__EXPRESSION:
				setExpression(EXPRESSION_EDEFAULT);
				return;
			case Nxtmodel2Package.CONDITION__VALUE:
				setValue(VALUE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Nxtmodel2Package.CONDITION__CONDITION_PROPERTY:
				return conditionProperty != null;
			case Nxtmodel2Package.CONDITION__TYPE:
				return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
			case Nxtmodel2Package.CONDITION__EXPRESSION:
				return EXPRESSION_EDEFAULT == null ? expression != null : !EXPRESSION_EDEFAULT.equals(expression);
			case Nxtmodel2Package.CONDITION__VALUE:
				return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (type: ");
		result.append(type);
		result.append(", expression: ");
		result.append(expression);
		result.append(", value: ");
		result.append(value);
		result.append(')');
		return result.toString();
	}

} //ConditionImpl
